/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pop3proxy.server;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author zero.one
 */
public class AccountManager {

    private List<Account> accList = new ArrayList<Account>();

    public AccountManager() {
    }

    public void addAccount(Account a) {
        if(!alreadySaved(a))
            accList.add(a);
    }

    public boolean alreadySaved(Account a) {
        for (Account aList : accList) {
            if (aList.equals(a)) {
                return true;
            }//equals
        }
        return false;
    }
    
    public List getAccList(){
        return accList;
    }
    
    public String toString(){
        String erg = "";
        for(Account a : accList){
            erg = erg + "["+a.getName()+","+a.getPassword()+"]";
        }
        return erg;
    }
}
